<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2018/7/27
 * Time: 16:44
 */

namespace app\alipay\model;

use app\account\model\UserManager;

class AddressManager extends UserManager{

    public function setAddress($uid, $name, $account){

        if(!empty($name)){
            $arrSeq["alipay_name"]=$name;
        }
        if(!empty($account)){
            $arrSeq["alipay_account"] = $account;
        }

        if(empty($arrSeq)){
            return false;
        }


        return $this->updateUserByCustom(array("uid"=>$uid),$arrSeq);
    }

    public function getAddress($uid){
        $result = $this->getUserByCustom(array("uid"=>$uid));
        if(!$result)
            return false;

        if(!$result["alipay_name"] || !$result["alipay_account"]){
            return false;
        }
        return array("name"=>$result["alipay_name"],"account"=>$result["alipay_account"]);
    }
}